package com.bw.module_message.view

import androidx.lifecycle.ViewModelProvider
import androidx.recyclerview.widget.LinearLayoutManager
import com.alibaba.android.arouter.facade.annotation.Route
import com.bw.lib_base.path.RouterPath
import com.bw.lib_common.view.BaseMvvmFragment
import com.bw.module_home.adapter.MsgAdapter
import com.bw.module_message.R
import com.bw.module_message.databinding.FragmentMessageBinding
import com.bw.smartpark_dl.login.MsgViewModel


@Route(path = RouterPath.PATH_FRAGMENT_MESSAGE)
class MessageFragment : BaseMvvmFragment<FragmentMessageBinding>() {

    lateinit var msgAdapter: MsgAdapter
    private val vm by lazy { ViewModelProvider(this)[MsgViewModel::class.java] }

    override fun loadData() {
        super.loadData()

        vm.mSuccessLiveData.observe(this){
            msgAdapter.data.clear()
            msgAdapter.data.addAll(it)
            msgAdapter.notifyDataSetChanged()
        }
    }

    override fun initViews() {
        msgAdapter= MsgAdapter()
        mDataBinding.rv.layoutManager= LinearLayoutManager(getContext())
        mDataBinding.rv.adapter=msgAdapter
        vm.getMsgList("111122223333",1)
    }


    override fun observeDataChange() {

    }

    override fun getLayoutId(): Int = R.layout.fragment_message
}